mock_instant
mock_instant
This crate allows you to test Instant/Duration code, deterministically per thread.
If cross-thread determinism is required, enable the sync
feature:
= { = "0.2", = ["sync"] }
It provides a replacement std::time::Instant
that uses a deterministic thread-local 'clock'
You can swap out the std::time::Instant
with this one by doing something similar to:
use Instant;
use Instant;
Example
use Duration;
let now = now;
advance;
advance;
// its been '17' seconds
assert_eq!;
License: 0BSD